<template>
  <div>
    <!-- 面包屑导航 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item><a href="/#/index/set">设置</a></el-breadcrumb-item>
      <el-breadcrumb-item>信息设置</el-breadcrumb-item>
    </el-breadcrumb>

    <!-- 卡片视图 -->
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <span style="padding-left: 20px">设置</span>
      </div>
      <el-row :gutter="40">
        <el-col :span="4">
          <el-menu
            :default-active="activePath"
            class="el-menu-vertical-demo"
            background-color="#efefef"
            text-color="#888"
            active-text-color="#2ec7bb"
            router>
            <el-menu-item :index="item.path" v-for="(item, index) in menuItem" :key="index" @click="saveNavState(item.path)">
              <!-- <i class="el-icon-menu"></i> -->
              <span slot="title">{{ item.title }}</span>
            </el-menu-item>
          </el-menu>
        </el-col>
        <el-col :span="10">
          <!-- 路由占位符 -->
          <router-view></router-view>
        </el-col>
      </el-row>
    </el-card>
  </div>
</template>

<script>
import { Session } from '@/assets/js/lib.js'
export default {
  data () {
    return {
      menuItem: [
        { id: 1, path: '/index/set/avator', title: '修改头像' },
        { id: 2, path: '/index/set/bio', title: '个人资料' },
        { id: 3, path: '/index/set/point', title: '积分' }
      ],
      activePath: ''
    }
  },
  created () {
    this.activePath = Session.get('activePath')
  },
  methods: {
    saveNavState (activePath) {
      Session.set('activePath', activePath)
      this.activePath = activePath
    }
  }
}
</script>

<style lang="less" scoped>
.el-card {
  margin-top: 20px;
}
</style>
